<%@ page language="java" isELIgnored="false" import="java.util.*" pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>抓取航线设置</title>
<base target="_self">
<link href="<%=request.getContextPath()%>/fare/css/base.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<%=request.getContextPath() %>/fare/js/show.js"></script>

<script type="text/javascript" src="<%=request.getContextPath()%>/fare/js/jquery-1.6.4.min.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/fare/js/datePicker/WdatePicker.js"></script>

<script type='text/javascript' src='<%=request.getContextPath()%>/fare/js/cityquery/citylist.js'></script>
<script type='text/javascript' src='<%=request.getContextPath()%>/fare/js/cityquery/querycity.js'></script>
<link href='<%=request.getContextPath()%>/fare/js/cityquery/cityquery.css' rel="stylesheet" type="text/css" />
<script type="text/javascript">
<!--
//保存抓取航空设置提交
function checkForm() {

	if ($("#grabChannel").val() == '') {
		alert("网站名称不能为空！");
		$("#grabChannel").focus();
		return false;
	}
	if ($("#fromCity").val() == '') {
		alert("航段不能为空！");
		$("#fromCity").focus();
		return false;
	}
	if ($("#toCity").val() == '') {
		alert("航段不能为空！");
		$("#toCity").focus();
		return false;
	}
	
	if(isNaN($("#formDateNumber").val())){
		alert("航班日期只能为数字！");
		$("#formDateNumber").focus();
		return false;
	}
	
	if ($("#formDateNumber").val() == '') {
		alert("航班日期不能为空！");
		$("#formDateNumber").focus();
		return false;
	}
	
	if(isNaN($("#toDateNumber").val())){
		alert("航班日期只能为数字！");
		$("#toDateNumber").focus();
		return false;
	}
	
	if ($("#toDateNumber").val() == '') {
		alert("航班日期不能为空！");
		$("#toDateNumber").focus();
		return false;
	}
	if ($("#validityFromStr").val() == ''
			|| $("#validityFromStr").val() == null) {
		alert("抓取时间段不能为空！");
		$("#validityFromStr").focus();
		return false;
	}
	if ($("#validityToStr").val() == ''
			|| $("#validityToStr").val() == null) {
		alert("抓取时间段不能为空！");
		$("#validityToStr").focus();
		return false;
	}
	if(isNaN($("#frequency").val())||$("#frequency").val()<0){
		alert("抓取频率只能为数字！且大于0");
		$("#frequency").focus();
		return false;
	}
	if ($("#frequency").val() == '') {
		alert("抓取频率不能为空！");
		$("#frequency").focus();
		return false;
	}
	if ($("#isReturn").val() == '1') {
		if ($("#returnDateScope").val() == '') {
		alert("抓取往返数据时，往返天数不能为空！");
		$("#returnDateScope").focus();
		return false;
		}
		if(isNaN($("#returnDateScope").val())){
			alert("抓取往返数据只能为数字！");
			$("#frequency").focus();
			return false;
		}
	}
	$("#taskForm").submit();
	alert("操作成功！");
	window.opener.showTaskInfoList(document.getElementById('grabChannel').value);
	window.close();
}
//-->
</script>
<script type="text/javascript"> 
	var msg='${mes}';
    if(msg != "" && msg != null && msg != "a"){
		alert(msg); 
	}
</script>
<script type="text/javascript">
	$(document).ready(function(){
		$('#fromCity').querycity({'data':citysFlight,'tabs':labelFromcity,'hotList':hotList});
		$('#toCity').querycity({'data':citysFlight,'tabs':labelFromcity,'hotList':hotList});
	});
	 
</script>
<style type="text/css">
<!--
.STYLE1 {
	color: #3366cc
}
-->
</style>
</head>

<body >
 <form id="taskForm" action="taskInfoAction!editTaskInfo.action" method="post" >
		<TABLE cellSpacing=1 cellPadding=3 width="100%" border=0 class="tabg">
			<TBODY>
				<TR class="tr1">
					<TD colspan="4">抓取航线设置</TD>
				</TR>
				<TR class="tab">
					<TD width="20%" height="26" style="text-align: left" class="td1">配置描述：
					</TD>
					<TD colspan="3"><textarea style="width: 550px; resize: none;" rows="3" cols="50" name="remark">${taskInfoVO.remark }</textarea></TD>
				</TR>
				<input type="hidden" name="taskId"  id ="taskId"  value="${taskInfoVO.id }" />
				<TR class="tab">
					<TD height="26" style="text-align: left" class="td1">网站名称：</TD>
					<TD colspan="3">
						<select class="easyui-combobox" name="grabChannel" style="width: 150px;" id="grabChannel">
							<c:choose>
								<c:when test="${sourceVOList == null}">
								</c:when>
								<c:otherwise>
									<c:forEach var="item" items="${sourceVOList }">
										<option value="${item.name}" <c:if test="${item.name==taskInfoVO.grabChannel }">selected='selected'</c:if>>${item.name}</option>
									</c:forEach>
								</c:otherwise>
							</c:choose>
						</select> 
						<!--  <br><input type="text" name="grabChannel" id="grabChannel"/> --> 
						<span style="color: #ff0000">*</span>
					</TD>
				</TR>
				<TR class="tab">
					<TD height="26" width="20%" style="text-align: left" class="td1">航&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;段：</TD>
					<TD width="40%">
						<div style='margin: 10px auto;'>
							<span>从</span> 
							<input id='fromCity' name="fromCity" type='text' value='${taskInfoVO.fromCityName }' style="width: 102px" /> 
							<span>到</span> 
							<input id='toCity' name="toCity" type='text' value='${taskInfoVO.toCityName }' style="width: 102px" />
							<span style="color: #ff0000">*</span><br />
						</div>
					</TD>
					<TD width="20%" style="text-align: left" class="td1">航班日期：</TD>
					<TD width="40%">
						<span>未来 </span> 
						<input type="text" maxlength="4" style="width: 30px" id="formDateNumber" value="${taskInfoVO.grabsopeBegin }" name="formDateNumber"> 
						<span>到</span> <input type="text" maxlength="4" style="width: 30px" id="toDateNumber" value="${taskInfoVO.grabsopeEnd }" name="toDateNumber"> 
						<span>天的航班</span> 
						<span style="color: #ff0000">*</span>
					</TD>
				</TR>
				<TR class="tab">
					<TD height="26" style="text-align: left" class="td1">抓取时间段：</TD>
					<TD>
						<span>从 </span> 
						<input type="text" style="width: 100px" id="validityFromStr" value="<fmt:formatDate pattern="yyyy-MM-dd" value="${taskInfoVO.validityFrom}" />" name="validityFromStr" 
						onClick="WdatePicker()"> 
						<span>到</span> 
						<input type="text" style="width: 100px" id="validityToStr" value="<fmt:formatDate pattern="yyyy-MM-dd" value="${taskInfoVO.validityTo}" />" name="validityToStr" 
						onClick="WdatePicker()"> 
						<span style="color: #ff0000">*</span>
					</TD>
					<TD style="text-align: left" class="td1">抓取频率：</TD>
					<TD>
						<span>每</span> 
						<input type="text" style="width: 30px" id="frequency" value="${taskInfoVO.frequency/60}" name="frequency"> 
						<span>小时抓去一次</span>
						<span style="color: #ff0000">*</span>
					</TD>
				</TR>
				<TR class="tab">
				<TD style="text-align: left" class="td1">是否抓取往返数据：</TD>
					<TD>
						<select id="isReturn" name="isReturn">
						<option value="1" <c:if test="${taskInfoVO.isReturn=='1' }">selected='selected'</c:if>>是</option>
						<option value="0" <c:if test="${taskInfoVO.isReturn=='0' }">selected='selected'</c:if>>否</option>
						</select>
					</TD>
					
					<TD style="text-align: left" class="td1">抓取往返天数：</TD>
					<TD>
						<span>从起飞日往后</span> 
						<input type="text" style="width: 30px" id="returnDateScope" value="${taskInfoVO.returnDateScope==0?3:taskInfoVO.returnDateScope }" name="returnDateScope"> 
						<span>天</span>
						<span style="color: #ff0000">*</span>
					</TD>
				</tr>
				<TR class="tab">
					<TD height="26" colspan="4" align="center">
						<input type="button" name="Submit222" value="保存" id="Submit222" style="width: 80px;cursor: pointer; cursor: hand;" 
						onclick="javascript:checkForm();">
							<input type="button" name="Submit222" value="取消" id="Submit222" style="width: 80px;cursor: pointer; cursor: hand;" 
						onclick="javascript:window.close();">
					</TD>
				</TR>
			</TBODY>
		</TABLE>
	</form>
</body>
</html>